<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;

use App\Models\User;

//使用类
use App\Http\Controllers\Controller;

//后台首页
class UserController extends Controller
{
    //会员首页
    public function index(Request $request){

            $search= $request->input('search');
            if($search){

                //获取总数据
                $tot= User::where("tel",'like','%'.$search.'%')->count();

                //从数据库中读取数据
                $data = User::where("tel",'like','%'.$search.'%')->paginate(5);

            }else{
                //获取总数据
                $tot= User::count();

                //从数据库中读取数据
                $data = User::paginate(5);
            }



        //加载页面
        return view("admin.user.index",['data'=>$data,'tot'=>$tot,'search'=>$search]);
    }



	
}
